<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Node</title>
  <script>
    window.onload = function () {
      // Node的属性和方法
      // 获取body节点
      var body = document.body;
      // console.log(body);
      // Document--> 9;
      // Element -->1;
      // TextNode -->3;
      // Comment--> 8
      // console.log(body.nodeType);  //1
      // console.log(body.nodeName);  //BODY
      // console.log(body.nodeValue);  //null
      // console.log(body.childNodes);  //NodeList的类数组对象
      var child = body.childNodes;
      // 将类数组对象转换为数组
      // var arr = Array.prototype.slice.call(child, 0);
      var arr = Array.from(child)
      // console.log(arr);
      // 实现从孩子节点中过滤出元素节点
      var res = arr.filter(function (item, index, arr) {
        return item.nodeType === 1;
      })
      // console.log(res)
      var one = document.getElementById('one')
      // console.log(one);
      // console.log(one.parentNode);  //body
      // console.log(one.previousSibling);  //hello
      // console.log(one.nextSibling);  //world
      // console.log(one.firstChild);  //div的文本
      // console.log(one.lastChild);  //div的文本
      console.log(one.ownerDocument);  //div的文本
      console.log(one.hasChildNodes());  //div的文本






    }
  </script>
</head>

<body>
  hello
  <div id="one" class="two">
    div的文本
  </div>
  world
  <!-- 注释 -->
</body>

</html>